package com.zhiwei.msf.infra.oauth.service.impl;

import com.zhiwei.msf.infra.oauth.mapper.AuthorityInfoMapper;
import com.zhiwei.msf.infra.oauth.service.AuthorityInfoService;
import com.zhiwei.msf.infra.oauth.entity.AuthorityInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;

@Service
public class AuthorityInfoServiceImpl implements AuthorityInfoService {

    @Autowired
    private AuthorityInfoMapper authorityInfoMapper;

    @Override
    public List<AuthorityInfo> selectByUserId(String uuid) {
        if (null == uuid) {
            return Collections.emptyList();
        }
        List<AuthorityInfo> authorityInfoList = authorityInfoMapper.selectByUserId(uuid);
        return CollectionUtils.isEmpty(authorityInfoList) ? Collections.emptyList() : authorityInfoList;
    }

    @Override
    public List<AuthorityInfo> queryAllAuthorities() {
        List<AuthorityInfo> authorityInfoList = authorityInfoMapper.queryAllAuthorities();
        return CollectionUtils.isEmpty(authorityInfoList) ? Collections.emptyList() : authorityInfoList;
    }
}